//
//  ToDoModel.swift
//
//  Created by 邱仙凯 on 2024/6/26
//  Copyright (c) . All rights reserved.
//

import Foundation
import ObjectMapper

public struct ToDoModel: Mappable {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    private struct SerializationKeys {
        static let instanceId = "instanceId"
        static let taskId = "taskId"
        static let userId = "userId"
        static let vouUrl = "vou_url"
        static let vouNo = "vou_no"
        static let readed = "readed"
        static let submitDt = "submit_dt"
        static let vouMemo = "vou_memo"
        static let auditReturnType = "type"
        static let vouId = "vou_id"
        static let content = "content"
        static let isPublic = "is_public"
        static let makeDt = "make_dt"
        static let submitNm = "submit_nm"
        static let id = "id"
        static let vocCd = "voc_cd"
        static let title = "title"
        static let nodeId = "nodeId"
        static let makerNm = "maker_nm"
        static let processId = "process_id"
        static let createTime = "createTime"
        static let vocNm = "voc_nm"
        static let isCustom = "is_custom"
        
        static let appMenuId = "app_menu_id"
        static let appMenuNm = "app_menu_nm"
        
        static let targetUser = "target_user"
        static let processDefName = "processDefName"
        static let cutype = "cutype"
        
        static let submiterId = "submiter_id"
        static let taskDefKey = "task_def_key_"
        static let todoType = "todo_type"
        static let nodeSelect = "node_select"
        static let dfType = "df_type"
        static let procInstId = "proc_inst_id_"
        static let eventTip = "event_tip"
        static let name = "name_"
        static let isView = "is_view"
        
        static let deptId = "dept_id"
        static let groupId = "group_id_"
        static let authFlage = "auth_flage"
        static let remindContent = "remind_content"
        static let handSign = "hand_sign"
        static let descriptionX = "description_"
        
        
        //99999
        static let postId = "post_id"
        static let verifyDtt = "verify_dtt"
        static let verifyMark = "verify_mark"
        static let submitStaffNm = "submit_staff_nm"
        static let waitTip = "wait_tip"
        static let useNewFlow = "use_new_flow"
        
        static let businessStatus = "business_status_"
        
        static let moduleId = "module_id"
        static let moduleIdNew = "module_id_new"
    }
    
    // MARK: Properties
    public var instanceId: String?
    public var taskId: String?
    public var userId: String?
    public var vouUrl: String?
    public var vouNo: String?
    public var readed: String?
    public var submitDt: String?
    public var vouMemo: String?
    public var auditReturnType: String?
    public var vouId: String?
    public var content: String?
    public var isPublic: String?
    public var makeDt: String?
    public var submitNm: String?
    public var id: String?
    public var vocCd: String?
    public var title: String?
    public var nodeId: String?
    public var makerNm: String?
    public var processId: String?
    public var createTime: String?
    public var vocNm: String?
    public var isCustom:String? // 1 启用了配置菜单  2  启用web表单
    public var processDefName: String?
    public var appMenuId:String?
    public var appMenuNm:String?
    public var cutype:String? // cutype =1 待审核 点击进入审核界面  cutype=2  待填单 点击进入填单界面
    
    // MARK: Properties
    public var submiterId: String?
    public var taskDefKey: String?
    public var todoType: String?
    public var nodeSelect: String?
    public var dfType: String?
    public var procInstId: String?
    
    public var eventTip: String?
    public var name: String?
    public var isView: String?
    
    public var deptId: String?
    public var groupId: String?
    public var authFlage: String?
    
    public var remindContent: String?
    public var handSign: String?
    
    public var descriptionX: String?
    
    public var postId: String?
    public var verifyDtt: String?
    public var verifyMark: String?
    public var submitStaffNm: String?
    public var waitTip: String?
    public var useNewFlow: String?
    
    public var isSelected = false
    public var businessStatus: String?
    
    public var moduleId: String?
    // 海新的 moduleId 字段特殊处理
    public var moduleIdNew: String?
    
    // MARK: ObjectMapper Initializers
    /// Map a JSON object to this class using ObjectMapper.
    ///
    /// - parameter map: A mapping from ObjectMapper.
    public init?(map: Map){
        
    }
    
    /// Map a JSON object to this class using ObjectMapper.
    ///
    /// - parameter map: A mapping from ObjectMapper.
    public mutating func mapping(map: Map) {
        instanceId <- map[SerializationKeys.instanceId]
        taskId <- map[SerializationKeys.taskId]
        userId <- map[SerializationKeys.userId]
        isCustom <- (map[SerializationKeys.isCustom],StringTransform())
        
        appMenuId <- (map[SerializationKeys.appMenuId],StringTransform())
        appMenuNm <- map[SerializationKeys.appMenuNm]
        
        vouUrl <- map[SerializationKeys.vouUrl]
        vouNo <- map[SerializationKeys.vouNo]
        readed <- (map[SerializationKeys.readed],StringTransform())
        submitDt <- map[SerializationKeys.submitDt]
        vouMemo <- map[SerializationKeys.vouMemo]
        auditReturnType <- map[SerializationKeys.auditReturnType]
        vouId <- (map[SerializationKeys.vouId],StringTransform())
        content <- map[SerializationKeys.content]
        isPublic <- map[SerializationKeys.isPublic]
        makeDt <- map[SerializationKeys.makeDt]
        cutype <- (map[SerializationKeys.cutype],StringTransform())
        procInstId <- (map[SerializationKeys.procInstId],StringTransform())
        
        
        submitNm <- map[SerializationKeys.submitNm]
        id <- map[SerializationKeys.id]
        vocCd <- map[SerializationKeys.vocCd]
        title <- map[SerializationKeys.title]
        nodeId <- map[SerializationKeys.nodeId]
        makerNm <- map[SerializationKeys.makerNm]
        processId <- map[SerializationKeys.processId]
        createTime <- map[SerializationKeys.createTime]
        vocNm <- map[SerializationKeys.vocNm]
        processDefName <- map[SerializationKeys.processDefName]
        
        submiterId <- (map[SerializationKeys.submiterId],StringTransform())
        
        taskDefKey <- map[SerializationKeys.taskDefKey]
        todoType <- (map[SerializationKeys.todoType],StringTransform())
        descriptionX <- map[SerializationKeys.descriptionX]
        
        nodeSelect <- (map[SerializationKeys.nodeSelect],StringTransform())
        dfType <- (map[SerializationKeys.dfType],StringTransform())
        
        isView <- (map[SerializationKeys.isView],StringTransform())
        handSign <- (map[SerializationKeys.handSign],StringTransform())
        
        eventTip <- map[SerializationKeys.eventTip]
        name <- map[SerializationKeys.name]
        vouMemo <- map[SerializationKeys.vouMemo]
        
        deptId <- (map[SerializationKeys.deptId],StringTransform())
        groupId <- (map[SerializationKeys.groupId],StringTransform())
        authFlage <- (map[SerializationKeys.authFlage],StringTransform())
        
        taskId <- (map[SerializationKeys.taskId],StringTransform())
        
        
        remindContent <- map[SerializationKeys.remindContent]
        
        postId <- map[SerializationKeys.postId]
        verifyDtt <- map[SerializationKeys.verifyDtt]
        verifyMark <- map[SerializationKeys.verifyMark]
        submitStaffNm <- map[SerializationKeys.submitStaffNm]
        waitTip <- map[SerializationKeys.waitTip]
        useNewFlow <- (map[SerializationKeys.useNewFlow],StringTransform())
        
        
        businessStatus <- (map[SerializationKeys.businessStatus], StringTransform())
        
        moduleId <- (map[SerializationKeys.moduleId], StringTransform())
        moduleIdNew <- (map[SerializationKeys.moduleIdNew], StringTransform())
    }
    
    //  /// Generates description of the object in the form of a NSDictionary.
    //  ///
    //  /// - returns: A Key value pair containing all valid values in the object.
    public func dictionaryRepresentation() -> [String: Any] {
        var dictionary: [String: Any] = [:]
        
        
        if let value = appMenuId { dictionary[SerializationKeys.appMenuId] = value }
        
        if let value = instanceId { dictionary[SerializationKeys.instanceId] = value }
        if let value = taskId { dictionary[SerializationKeys.taskId] = value }
        if let value = userId { dictionary[SerializationKeys.userId] = value }
        if let value = vouUrl { dictionary[SerializationKeys.vouUrl] = value }
        if let value = vouNo { dictionary[SerializationKeys.vouNo] = value }
        dictionary[SerializationKeys.readed] = readed
        if let value = submitDt { dictionary[SerializationKeys.submitDt] = value }
        if let value = vouMemo { dictionary[SerializationKeys.vouMemo] = value }
        if let value = auditReturnType { dictionary[SerializationKeys.auditReturnType] = value }
        if let value = vouId { dictionary[SerializationKeys.vouId] = value }
        if let value = content { dictionary[SerializationKeys.content] = value }
        if let value = isPublic { dictionary[SerializationKeys.isPublic] = value }
        if let value = makeDt { dictionary[SerializationKeys.makeDt] = value }
        if let value = submitNm { dictionary[SerializationKeys.submitNm] = value }
        if let value = id { dictionary[SerializationKeys.id] = value }
        if let value = vocCd { dictionary[SerializationKeys.vocCd] = value }
        if let value = title { dictionary[SerializationKeys.title] = value }
        if let value = nodeId { dictionary[SerializationKeys.nodeId] = value }
        if let value = makerNm { dictionary[SerializationKeys.makerNm] = value }
        if let value = processId { dictionary[SerializationKeys.processId] = value }
        if let value = createTime { dictionary[SerializationKeys.createTime] = value }
        if let value = vocNm { dictionary[SerializationKeys.vocNm] = value }
        if let value = businessStatus { dictionary[SerializationKeys.businessStatus] = value }
        if let value = moduleId { dictionary[SerializationKeys.moduleId] = value }
        if let value = moduleIdNew { dictionary[SerializationKeys.moduleIdNew] = value }
        return dictionary
    }
    
}
public struct Props: Mappable {
    
    var requiredx: String?
    
    
    
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public  func mapping(map: Map) {
        requiredx <- (map["required"],StringTransform_bool())
        
        
    }
    
}
struct ChooseUsers: Mappable {
    
    var nodeName: String?
    var nodeId: String?
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        nodeName <- map["nodeName"]
        nodeId <- (map["nodeId"],StringTransform())
    }
}
struct TaskSetResult: Mappable {
    
    var chooseUsers = [ChooseUsers]()
    var id_key: String?
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        chooseUsers <- map["chooseUsers"]
        id_key <- (map["id_key"],StringTransform())
    }
}


struct DraftFileResult: Mappable {
    
    var fileName: String?
    var filePath: String?
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        fileName <- map["fileName"]
        filePath <- map["filePath"]
        
        
    }
}



struct TodoFormItems: Mappable {
    
    var title: String?
    var value:String?
    var id: String?
    var columnName:String?
    var perm:String? // R 只读   E 编辑
    var props:Props?
    
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        title <- map["title"]
        value <- (map["value"],StringTransform())
        columnName <- map["columnName"]
        id <- map["id"]
        perm <- map["perm"]
        props <- map["props"]
        
    }
    public func dictionaryRepresentation() -> [String: Any] {
        var dictionary: [String: Any] = [:]
        if let value = value { dictionary["value"] = value }
        if let value = id { dictionary["id"] = value }
        if let value = columnName { dictionary["columnName"] = value }
        
        return dictionary
    }
}
public struct TodopProgress: Mappable {
    
    var name: String?
    var userinfo = [ProgressUser]()
    var startTime:String?
    var title:String?
    var user:String?
    var userid:String?
    var finishTime:String?
    var taskstats:String?
    var result:String?
    var text:String?
    var nodeType:String?
    var taskId :String?
    var nodeId:String?
    
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public  func mapping(map: Map) {
        name <- map["name"]
        title <- map["title"]
        user <- map["user"]
        userid <- map["userid"]
        
        
        text <- map["text"]
        nodeType <- map["nodeType"]
        finishTime <- map["finishTime"]
        taskstats <- map["taskstats"]
        
        userinfo <- map["userinfo"]
        startTime <- map["startTime"]
        result <- map["result"]
        taskId <- map["taskId"]
        nodeId <- map["nodeId"]
    }
    
}
public struct OperationPerm: Mappable {
    
    var refuse: BtnPerm?
    var transfer: BtnPerm?
    var afterAdd:BtnPerm?
    var recall:BtnPerm?
    var agree:BtnPerm?
    var comment:BtnPerm?
    var readed:BtnPerm?
    
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public  func mapping(map: Map) {
        refuse <- map["refuse"]
        transfer <- map["transfer"]
        afterAdd <- map["afterAdd"]
        recall <- map["recall"]
        agree <- map["agree"]
        comment <- map["comment"]
        readed <- map["readed"]
        
    }
    
}

public struct BtnPerm: Mappable {
    
    var alisa: String? // 手动设置  查看，光看不操作 view
    var show: Bool?
    
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public  func mapping(map: Map) {
        alisa <- map["alisa"]
        show <- map["show"]
        
    }
    
}
public struct ProgressUser: Mappable {
    var userid:String?
    var user: String?
    var nodeType:String?
    var submit_dt:String?
    var taskId :String?
    var nodeId:String?
    var attachments = [attachmentsModel]()
    var comment = [commentModel]()
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public func mapping(map: Map) {
        user <- map["user"]
        nodeType <- map["nodeType"]
        submit_dt <- map["submit_dt"]
        userid <- map["userid"]
        comment <- map["comment"]
        attachments <- map["attachments"]
        taskId <- map["taskId"]
        nodeId <- map["nodeId"]
    }
    
}

public struct commentModel: Mappable {
    
    
    var text :String?
    var user: String?
    var comment: String?
    
    var createTime:String?
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public func mapping(map: Map) {
        text <- map["text"]
        createTime <- map["createTime"]
        comment <- map["comment"]
        
        
        user <- map["user"]
        
    }
    
}

public struct attachmentsModel: Mappable {
    
    var name: String?
    var id: String?
    var url: String?
    
    public init?(map: Map) {
        
    }
    // Mappable
    mutating public func mapping(map: Map) {
        
        name <- map["name"]
        id <- map["id"]
        url <- map["url"]
        
        
    }
    
}



struct HistoryAuditModel: Mappable {
    
    var post_nm: String?
    var staff_nm: String?
    var audit_dt:String?
    var submit_dt:String?
    
    var submit_nm:String?
    var verfymark:String?
    var memo:String?
    init?(map: Map) {
        
    }
    // Mappable
    mutating func mapping(map: Map) {
        post_nm <- map["post_nm"]
        staff_nm <- map["staff_nm"]
        audit_dt <- map["audit_dt"]
        submit_dt <- map["submit_dt"]
        submit_nm <- map["submit_nm"]
        verfymark <- map["verfymark"]
        memo <- map["memo"]
        
        
    }
    
}
